/**
 * 银行卡详情对话框（可用于添加和修改对话框）
 */
var bankcardInfoDlg = {
    data: {
        cardId: "",
        userId: "",
        cardName: "",
        cardPhone: "",
        cardNumber: "",
        cardPassword: "",
        cardMoney: ""
    }
};

/**
 * 表单验证
 * @returns {*}
 */
bankcardInfoDlg.validateForm = function () {

    var data = bankcardInfoDlg.data;

    if (!data.cardName) {
        return "请输入姓名";
    }
    if (!data.cardPhone) {
        return "请输入联系电话";
    }
    if (!data.cardMoney) {
        return "请输入金额";
    }
    return true;
};

/**
 * 关闭此对话框
 */
bankcardInfoDlg.close = function () {
    parent.layer.close(window.parent.bankcard.layerIndex);
};
/**
 * 提交修改
 */
bankcardInfoDlg.editSubmit = function () {
    var ajax = new $ax(Feng.ctxPath + "/bankcard/edit", function (data) {
        window.parent.Feng.success("修改成功!");
        if (window.parent.bankcard !== undefined) {
            window.parent.bankcard.table.refresh();
            bankcardInfoDlg.close();
        }
    }, function (data) {
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(bankcardInfoDlg.data);
    ajax.start();
};
/**
 * 刚进入页面就获取
 */
$(function () {
    //获取车辆信息
    var ajax = new $ax(Feng.ctxPath + "/bankcard/look");
    var result = ajax.start();
    bankcardInfoDlg.data = result.data;
    bankcardInfoDlg.app = new Vue({
        el: '#bankcardForm',
        data: bankcardInfoDlg.data,
        methods: {
            submitForm: function (e) {
                e.preventDefault();
            },
            ensure: function () {
                var result = bankcardInfoDlg.validateForm();
                if (result === true) {
                    bankcardInfoDlg.editSubmit();
                } else {
                    Feng.alert(result);
                }
            },
            close: function () {
                bankcardInfoDlg.close();
            }
        }
    });
});
